<?php
function EventsBuildAdminMenuHook($backend)
{
	if(cr("EventConfig.enable_events"))
	{
		$backend->addMenuItem(ADMIN_CONTENT, __('Event Categories'),'/events/event_categories/index');
		$backend->addMenuItem(ADMIN_CONTENT, __('Events'),'/events/events/index/');
	}
	$backend->addMenuItem(ADMIN_SETTINGS, __('Event Settings'),'/events/event_config/setting/Event');
}

function EventsGetSiteMapPagesHook(SiteMap $SiteMapModel)
{
	if(!cr("EventConfig.enable_events"))
	{
		return;
	}
	if(!checkSessionKeyForEvents())
	{
		return;
	}
	
	$eventIndexPages = new GigaAction(
			"eventIndex",
			__('Event Index'),
			array("controller"=>"events","action"=>"index","plugin"=>"events")
	);
	$eventViewPage = new GigaAction(
			"eventView",
			__('Event View'),
			array("controller"=>"events","action"=>"view","plugin"=>"events")
	);
	$browseEventPages = new GigaAction(
			"browseEvents",
			__('Browse Events'),
			array("controller"=>"events","action"=>"browse","plugin"=>"events")
	);
	$addEvent = new GigaAction(
			"eventAdd",
			__('Add Event'),
			array("controller"=>"events","action"=>"add","plugin"=>"events")
	);
	$editEvent = new GigaAction(
			"eventEdit",
			__('Edit Event'),
			array("controller"=>"events","action"=>"edit","plugin"=>"events")
	);

	$pages = array($eventIndexPages,$eventViewPage,$browseEventPages,$addEvent,$editEvent);
	$SiteMapModel->pages = am($SiteMapModel->pages,$pages);
}

function EventsAfterComponentInitHook($ctrl)
{
	App::import("Vendor","Events.EventsUtility");
	EventsUtility::initializeConfiguration();
}

function EventsBeforeShellDispatchHook($ctrl)
{
	App::import("Vendor","Events.EventsUtility");
	EventsUtility::initializeConfiguration();
}

function EventsGetNewsletterTypesHook($model)
{
	if(isset($model->newsletterTypes))
	{
		$model->newsletterTypes[] = array(
				"type"        => "event",
				"label"       => __("Event newsletter"),
				"contentCall" => "Events.EventNewsletterHandler"
		);
	}
}
?>